#include <bits/stdc++.h>
#define int long long
#define ffor(i, a, b) for (int i = (a); i <= (b); i++)
#define roff(i, a, b) for (int i = (a); i >= (b); i--)
using namespace std;
const int MAXN = 1e4 + 10, MAXM = 1230;
int n, m, dp[MAXM][MAXN], vis[MAXN];
vector<int> pr;
void init(int MAX) {
  pr.push_back(0);
  ffor(i, 2, MAX) {
    if (!vis[i]) pr.push_back(i);
    for (int j = 1; j < pr.size() && pr[j] * i <= MAX; j++) {
      vis[i * pr[j]] = 1;
      if (i % pr[j] == 0) break;
    }
  }
  return;
}
signed main() {
  scanf("%lld %lld", &n, &m);
  init(n);
  dp[0][0] = 1;
  ffor(i, 1, pr.size() - 1) {
    int base = pr[i];
    ffor(j, 0, n) dp[i][j] = dp[i - 1][j];
    while (base <= n) {
      ffor(j, base, n) dp[i][j] += dp[i - 1][j - base] * base, dp[i][j] %= m;
      base *= pr[i];
    }
  }
  int ans = 0;
  ffor(i, 0, n) ans += dp[pr.size() - 1][i], ans %= m;
  printf("%lld", ans);
  return 0;
}
